
$(function() {
    validateRule();
	$('.imgcode').click(function() {
		var url = ctx + "sys/captchaImage/" + captchaType + "/" + Math.random();
		$(".imgcode").attr("src", url);
	});
	$('#btnSubmit').click(function () {
	    var pwd = $('input[name=password]').val();
        $('input[name=password]').val($.md5(pwd));
        login();
    });
});

function login() {
	$.modal.loading($("#btnSubmit").data("loading"));
	if($("#signupForm").valid()){
        $("#signupForm").submit();
	}
}

function validateRule() {
    var icon = "<i class='fa fa-times-circle'></i> ";
    $("#signupForm").validate({
        rules: {
            username: {
                required: true
            },
            password: {
                required: true
            }
        },
        messages: {
            username: {
                required: icon + "请输入您的用户名",
            },
            password: {
                required: icon + "请输入您的密码",
            }
        }
    })
}
